import React, { useEffect, useState } from "react";
import Item from "./item";
import pubsub from 'pubsub-js'
export default function List() {
    const [gainList , setGainList] = useState({
        isInit : true,
        isSearch : false,
        data : []
    })
    useEffect(() => {
        pubsub.subscribe('github',( _ , data) =>{
            setGainList(data)
        })
    },[])
  return (
    <div>
      <div className="row">
            {
                gainList.isInit?(<h2>请开始搜索</h2>):gainList.isSearch?(<h2>正在搜索中</h2>):gainList.data.map(item =>{
                    return <Item key={item.id} {...item}/>
                })
            }
      </div>
    </div>
  );
}
